<?php
use yii\helpers\Url;
use yii\widgets\LinkPager;
/* @var $this yii\web\View */

?>
<div id="page-wrapper" style="min-height: 362px;">
    <div class="row">
        <div class="col-lg-12">
            <h1 class="page-header">
                <a href="<?= Url::to(['manage/notice-edit'])?>" class="btn btn-primary">添加</a>
            </h1>
        </div>
    </div>

    <div class="row">
        <div class="col-lg-12">
            <table class="table table-striped table-bordered table-hover dataTable no-footer" id="dataTables-example" role="grid" aria-describedby="dataTables-example_info">
                <thead>
                <tr role="row">
                    <th style="">ID</th>
                    <th style="">标题</th>
                    <th style="">页面类型</th>
                    <th style="">排序</th>
                    <th style="">发布时间</th>
                    <th style=""></th>
                </thead>
                <tbody>
                <?php
                $trs = '';
                foreach($models as $model) {
                    $time = date('Y-m-d H:i:s',$model->created_at);
                    $url = Url::to(['manage/notice-edit','id'=>$model->id]);
                    $type = \app\models\Notice::$typeArray[$model->type];
                    $trs.=<<<TR
                <tr class="gradeA odd" role="row">
                    <td class="center">{$model->id}</td>

                    <td class="center">{$model->title}</td>
                    <td class="center">{$type}</td>
                    <td class="center">{$model->sort}</td>
                    <td class="center">{$time}</td>
                    <td class="center"><a href="javascript:;" onclick="del({$model->id});">删除</a> |  <a href="{$url}">编辑</a> </td>
                </tr>
TR;

                }
                echo $trs;
                ?>

                </tbody>
            </table>
            <div class="row">
                <div class="col-sm-6">
                    <div class="dataTables_paginate paging_simple_numbers">
                            <?php
                             echo LinkPager::widget([
                                  'pagination' => $pages,
                              ]);
                            ?>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<script>
    function del(n){
        if(confirm('确定删除此？')){
            $.post('<?= Url::to(['manage/delnotice']) ?>',{id:n,'<?= Yii::$app->request->csrfParam ?>':'<?= Yii::$app->request->getCsrfToken() ?>'},function(v){
                if(v.f){
                    alert('删除成功！');
                    location.reload();
                }else{
                    alert(v.data);
                }
            },'json');
        }
    }
    function ck(n){
        $('.form-inline').submit();
    }
</script>



